package demoMod.nanaki.powers;

import com.megacrit.cardcrawl.actions.common.RemoveSpecificPowerAction;
import com.megacrit.cardcrawl.cards.DamageInfo;
import com.megacrit.cardcrawl.core.AbstractCreature;
import com.megacrit.cardcrawl.core.CardCrawlGame;
import com.megacrit.cardcrawl.localization.PowerStrings;
import com.megacrit.cardcrawl.powers.AbstractPower;
import demoMod.nanaki.NanakiMod;
import demoMod.nanaki.interfaces.NoteExplodeHook;
import demoMod.nanaki.utils.PowerRegionLoader;

public class SoulOfStareyePower extends AbstractPower implements NoteExplodeHook {
    public static final String POWER_ID = NanakiMod.makeID("SoulOfStareyePower");
    private static final PowerStrings powerStrings;
    public static final String NAME;
    public static final String[] DESC;

    public SoulOfStareyePower(AbstractCreature owner, int amount) {
        this.name = NAME;
        this.ID = POWER_ID;
        this.owner = owner;
        this.amount = amount;
        this.updateDescription();
        PowerRegionLoader.load(this);
        this.type = PowerType.DEBUFF;
    }

    @Override
    public void updateDescription() {
        this.description = String.format(DESC[0], this.amount + 1);
    }

    @Override
    public boolean shouldExplode(AbstractCreature target) {
        return true;
    }

    @Override
    public int reduceExplodeAmount(int reduceAmount) {
        return reduceAmount;
    }

    @Override
    public int modifyExplodeDamage(int damageAmount) {
        return damageAmount * (this.amount + 1);
    }

    @Override
    public int onAttacked(DamageInfo info, int damageAmount) {
        if (info.type == DamageInfo.DamageType.THORNS && info.owner != null && info.owner == this.owner) {
            this.flash();
            addToBot(new RemoveSpecificPowerAction(owner, owner, this));
        }
        return damageAmount;
    }

    static {
        powerStrings = CardCrawlGame.languagePack.getPowerStrings(POWER_ID);
        NAME = powerStrings.NAME;
        DESC = powerStrings.DESCRIPTIONS;
    }
}
